﻿<local:ResizableRectangle 
    x:Class="ImageCropper.ImageRectangle"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
    xmlns:local="clr-namespace:ImageCropper"
    IsTabStop="True"
    KeyDown="ResizableRectangle_KeyDown"
    GotFocus="ResizableRectangle_GotFocus"
    LostFocus="ResizableRectangle_LostFocus"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
    
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <vsm:VisualStateManager.VisualStateGroups>
            <vsm:VisualStateGroup x:Name="CommonStates">
                <vsm:VisualState x:Name="Normal"/>
                <vsm:VisualState x:Name="MouseOver"/>
                <vsm:VisualState x:Name="Pressed"/>
                <vsm:VisualState x:Name="Disabled"/>
            </vsm:VisualStateGroup>
            <vsm:VisualStateGroup x:Name="FocusStates">
                <vsm:VisualState x:Name="Focused">
                    <Storyboard>
                        <DoubleAnimation From="1" To="2" 
                                         Duration="0:0:0.25"
                                         Storyboard.TargetName="_border" 
                                         Storyboard.TargetProperty="StrokeThickness"/>
                        <DoubleAnimation From="20" To="0"
                                         BeginTime="0:0:0.25"
                                         Duration="0:0:1"
                                         Storyboard.TargetName="_border" 
                                         Storyboard.TargetProperty="StrokeDashOffset" 
                                         RepeatBehavior="Forever"/>
                    </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="Unfocused"/>
            </vsm:VisualStateGroup>
        </vsm:VisualStateManager.VisualStateGroups>
        <Image x:Name="_image" Stretch="None"/>
        <Rectangle x:Name="_border" Margin="0" StrokeThickness="1" Stroke="#88FFFFFF" StrokeDashArray="5,5" Grid.ColumnSpan="3" Grid.RowSpan="3"/>
        <Rectangle
            x:Name="_center"
            MouseMove="_center_MouseMove"
            Cursor="Hand" Fill="Transparent" Grid.Row="1" Grid.Column="1"/>
    </Grid>
</local:ResizableRectangle>
